﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace Test
{
    public partial class Form1 : Form
    {
        CardBase mCardMang;
        int mCutPostion = 30;
        public Form1()
        {
            InitializeComponent();
            mCardMang=new CardBase(10,null);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            mCardMang.Init();
            mCardMang.Dispense(2, panel1, CardOrientation.Top,false);
            mCardMang.Dispense(2, panel4, CardOrientation.Botton,false);
            mCardMang.Dispense(2, panel2, CardOrientation.Left, false);
            mCardMang.Dispense(2, panel3, CardOrientation.Right, false);
        }

        void tmpPBox_MouseLeave(object sender, EventArgs e)
        {
            (sender as PictureBox).Location = new Point((sender as PictureBox).Location.X, 15);
        }

        void tmpPBox_MouseEnter(object sender, EventArgs e)
        {
            (sender as PictureBox).Location = new Point((sender as PictureBox).Location.X, (sender as PictureBox).Location.Y - 14);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            
            Card tmpCard = mCardMang.CutCards(mCutPostion);
            pictureBox1.Image = tmpCard.CardImg;
            int tmpCurPanel = (int)tmpCard.CardNum % 4 == 0 ? 4 : (int)tmpCard.CardNum % 4;
            label1.Text = Convert.ToString(tmpCurPanel);
            Panel[] tmpCurPanels = new Panel[] { panel1, panel2, panel3, panel4 };
            Label[] tmpCountLab = new Label[] { label6, label7, label8, label9 };
            panel1.BackColor = panel2.BackColor = panel3.BackColor = panel4.BackColor = Color.White;
            tmpCurPanels[tmpCurPanel - 1].BackColor = Color.LightBlue;
            tmpCountLab[tmpCurPanel - 1].Tag = Convert.ToInt32(tmpCountLab[tmpCurPanel - 1].Tag) + 1;
            tmpCountLab[tmpCurPanel - 1].Text = Convert.ToString(tmpCountLab[tmpCurPanel - 1].Tag);

            for (int i = tmpCurPanel - 1; i < tmpCurPanels.Length; i++)
                mCardMang.Dispense(2, tmpCurPanels[i], CardOrientation.Botton, false);
            for (int i = 0; i < tmpCurPanel-1; i++)
                mCardMang.Dispense(2, tmpCurPanels[i], CardOrientation.Botton, false);
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            mCutPostion = 30;
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            mCutPostion = 60;
        }

        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
            mCutPostion = 90;
        }

        private void panel5_Paint(object sender, PaintEventArgs e)
        {

        }
    }
}
